package vo

import (
	"github.com/spf13/cast"
	"honghu_be/dal/po"
)

type BoxVo struct {
	BoxId string `json:"box_id"`
	Image string `json:"image"`
	Title string `json:"title"`
	Link  string `json:"link"`
}

func (b *BoxVo) ToPo() *po.Box {
	return &po.Box{
		Image: b.Image,
		Title: b.Title,
		Link:  b.Link,
	}
}

func ToBoxVo(b *po.Box) *BoxVo {
	return &BoxVo{
		BoxId: cast.ToString(b.ID),
		Image: b.Image,
		Title: b.Title,
		Link:  b.Link,
	}
}

func ToBoxVos(pos []*po.Box) []*BoxVo {
	vos := make([]*BoxVo, len(pos))
	for i := range pos {
		vos[i] = ToBoxVo(pos[i])
	}
	return vos
}
